<?php

/**
 * This is the model class for table "pengaduan".
 *
 * The followings are the available columns in table 'pengaduan':
 * @property integer $id
 * @property string $nama_pelapor
 * @property string $no_ktp_pelapor
 * @property string $alamat_pelapor
 * @property string $email_pelapor
 * @property string $telp_pelapor
 * @property string $nama_terlapor
 * @property string $jabatan_terlapor
 * @property string $satker_terlapor
 * @property string $subjek_pengaduan
 * @property string $isi_pengaduan
 * @property integer $created_by
 * @property string $created_time
 * @property integer $updated_by
 * @property string $updated_time
 */
class Pengaduan extends MyModel
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pengaduan';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('nama_pelapor, nama_terlapor, no_ktp_pelapor, alamat_pelapor, telp_pelapor, subjek_pengaduan, isi_pengaduan', 'required'),
			array('nama_pelapor, email_pelapor, subjek_pengaduan ', 'required'),
			array('created_by, updated_by', 'numerical', 'integerOnly'=>true),
			array('nama_pelapor, nama_terlapor', 'length', 'max'=>100),
			array('no_ktp_pelapor', 'length', 'max'=>20),
			array('alamat_pelapor, subjek_pengaduan', 'length', 'max'=>255),
			array('email_pelapor, telp_pelapor, jabatan_terlapor, satker_terlapor', 'length', 'max'=>50),
			array('isi_pengaduan, tanggapan', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, nama_pelapor, no_ktp_pelapor, alamat_pelapor, email_pelapor, telp_pelapor, nama_terlapor, jabatan_terlapor, satker_terlapor, subjek_pengaduan, isi_pengaduan, created_by, created_time, updated_by, updated_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nama_pelapor' => 'Nama Pelapor',
			'no_ktp_pelapor' => 'No Ktp Pelapor',
			'alamat_pelapor' => 'Alamat Pelapor',
			'email_pelapor' => 'Email Pelapor',
			'telp_pelapor' => 'Telp Pelapor',
			'nama_terlapor' => 'Nama Terlapor',
			'jabatan_terlapor' => 'Jabatan Terlapor',
			'satker_terlapor' => 'Satuan Kerja',
			'subjek_pengaduan' => 'Subjek Pengaduan',
			'isi_pengaduan' => 'Isi Pengaduan',
			'created_by' => 'Created By',
			'created_time' => 'Created Time',
			'updated_by' => 'Updated By',
			'updated_time' => 'Updated Time',
			'tanggapan' => 'Tanggapan',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('nama_pelapor',$this->nama_pelapor,true);
		$criteria->compare('no_ktp_pelapor',$this->no_ktp_pelapor,true);
		$criteria->compare('alamat_pelapor',$this->alamat_pelapor,true);
		$criteria->compare('email_pelapor',$this->email_pelapor,true);
		$criteria->compare('telp_pelapor',$this->telp_pelapor,true);
		$criteria->compare('nama_terlapor',$this->nama_terlapor,true);
		$criteria->compare('jabatan_terlapor',$this->jabatan_terlapor,true);
		$criteria->compare('satker_terlapor',$this->satker_terlapor,true);
		$criteria->compare('subjek_pengaduan',$this->subjek_pengaduan,true);
		$criteria->compare('isi_pengaduan',$this->isi_pengaduan,true);
		$criteria->compare('created_by',$this->created_by);
		$criteria->compare('created_time',$this->created_time,true);
		$criteria->compare('updated_by',$this->updated_by);
		$criteria->compare('updated_time',$this->updated_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Pengaduan the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
